﻿@using Bonobo.Git.Server.Extensions;
@model IList<TeamDetailModel>
@{
    ViewBag.Title = Resources.Team_Index_Title;
}
<h2>@Resources.Team_Index_Title</h2>
@if (TempData["CreateSuccess"] != null && (bool)TempData["CreateSuccess"])
{
    <div class="uniForm">    
        <div id="okMsg">
            <p>@Resources.Team_Create_Success</p>
        </div>
    </div>
}
@if (TempData["DeleteSuccess"] != null && (bool)TempData["DeleteSuccess"])
{
    <div class="uniForm">    
        <div id="okMsg">
            <p>@Resources.Team_Delete_Success</p>
        </div>
    </div> 
}
@{
    var grid = new WebGrid(source: Model, defaultSort: "Name", rowsPerPage: 15);
}
<div class="create">@Html.ActionLink(Resources.Team_Index_CreateNew, "Create")</div>
<h3>@Resources.Team_Index_Teams</h3>
<div class="w-grid">
    @grid.GetHtml(
        tableStyle: "grid",
        headerStyle: "head",
        alternatingRowStyle: "even",
        columns: grid.Columns(
            grid.Column(header: typeof(TeamDetailModel).GetDisplayValue("Name"), format: (item) => Html.ActionLink((string)item.Name, "Detail", new { id = item.Name }, new { @class = "team" })),
            grid.Column("Description", typeof(TeamDetailModel).GetDisplayValue("Description"), format: (item) => item.Description != null && ((string)item.Description).Length > 100 ? ((string)item.Description).Substring(0, 100) + " (...) " : item.Description),
            grid.Column(format: (item) => Html.ActionLink(Resources.Grid_Edit, "Edit", new { id = item.Name }), style: "action"),
            grid.Column(format: (item) => Html.ActionLink(Resources.Grid_Delete, "Delete", new { id = item.Name }, new { @class = "deleteButton" }), style: "action")
        )
    )
</div>
